#!/usr/local/bin/python2.7
# encoding: utf-8
'''
Adb.AdbFactory -- shortdesc

Adb.AdbFactory is a description

It defines classes_and_methods

@author:     Anson Chan

@copyright:  2016 Xerland Co. Ltd. All rights reserved.

@contact:    anson_chan@xerland.com
@deffield    updated: Updated
'''
import win32com
import win32com.client
import traceback
import time
import datetime
DSN = r'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=C:\Program Files (x86)\SysControl\WatchData.mdb;Persist Security Info=False;Jet OLEDB:Database Password=090458'
Table_Name = 'RealTimeData'

if __name__ == '__main__':
    try:
        conn = win32com.client.Dispatch(r'ADODB.Connection')
        conn.Open(DSN)
        rs = win32com.client.Dispatch(r'ADODB.Recordset')
        rs.Open('[' + Table_Name + ']', conn, 1, 3)
        while 1:
            rs.AddNew()
            rs.Fields.Item(2).Value = datetime.datetime.now().strftime('%m/%d/%Y %H:%M:%S')
            rs.Fields.Item(1).Value = 2
            rs.Update()
            time.sleep(3)
            
        
    except Exception, e:
        traceback.print_exc()
        
    finally:
        conn.Close()
        
